package com.mercury.pattern._10_flyweight;

/**
 *
 */
public class Client {
    public static void main(String[] args) {
        WebSiteFactory factory = new WebSiteFactory();

        WebSite news = factory.getWebSite("新闻");
        WebSite blog = factory.getWebSite("博客");
        WebSite wechat = factory.getWebSite("微信公众号");
        WebSite wechat2 = factory.getWebSite("微信公众号");
        news.use(new User("tom"));
        blog.use(new User("jack"));
        wechat.use(new User("jerry"));
        wechat2.use(new User("coffee"));

        //虽然使用者有四个，但是总数还是为3；所以type是内部状态，user是外部状态
        System.out.println("总数为：" + factory.getCount());
    }
}